package com.irdstudio.tdp.console.api.rest;

import java.util.List;

import com.irdstudio.sdk.beans.core.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.irdstudio.tdp.console.service.facade.OsrvLinkedCondService;
import com.irdstudio.tdp.console.service.vo.OsrvLinkedCondVO;
import com.irdstudio.sdk.beans.core.vo.ResponseData;
import com.irdstudio.sdk.ssm.web.AbstractController;

@RestController
@RequestMapping("/api")
public class OsrvLinkedCondController extends AbstractController  {
	
	@Autowired
	@Qualifier("osrvLinkedCondServiceImpl")
	private OsrvLinkedCondService osrvLinkedCondService;

	
	/**
	 * 列表数据查询
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping(value="/osrv/linked/conds", method=RequestMethod.POST)
	public @ResponseBody ResponseData<List<OsrvLinkedCondVO>> queryOsrvLinkedCondAll(
			OsrvLinkedCondVO vo) {		
		List<OsrvLinkedCondVO> outputVo = osrvLinkedCondService.queryAllOwner(vo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键查询详情
	 * @return
	 */
	@RequestMapping(value="/osrv/linked/cond/{condId}", method=RequestMethod.GET)
	public @ResponseBody ResponseData<OsrvLinkedCondVO> queryByPk(@PathVariable("condId") String condId) {		
		OsrvLinkedCondVO inVo = new OsrvLinkedCondVO();
				inVo.setCondId(condId);
		OsrvLinkedCondVO outputVo = osrvLinkedCondService.queryByPk(inVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键删除信息
	 * @param osrvLinkedCond
	 * @return
	 */
	@RequestMapping(value="/osrv/linked/cond", method=RequestMethod.DELETE)
	public @ResponseBody ResponseData<Integer> deleteByPk(@RequestBody OsrvLinkedCondVO inOsrvLinkedCondVo) {		
		int outputVo = osrvLinkedCondService.deleteByPk(inOsrvLinkedCondVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键更新信息
	 * @param inOsrvLinkedCondVo
	 * @return
	 */
	@RequestMapping(value="/osrv/linked/cond", method=RequestMethod.PUT)
	public @ResponseBody ResponseData<Integer> updateByPk(@RequestBody OsrvLinkedCondVO inOsrvLinkedCondVo) {		
		int outputVo = osrvLinkedCondService.updateByPk(inOsrvLinkedCondVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 新增数据
	 * @param inOsrvLinkedCondVo
	 * @return
	 */
	@RequestMapping(value="/osrv/linked/cond", method=RequestMethod.POST)
	public @ResponseBody ResponseData<String> insertOsrvLinkedCond(@RequestBody OsrvLinkedCondVO inOsrvLinkedCondVo) {
		inOsrvLinkedCondVo.setCondId(UUIDUtil.getUUID());
		int outputVo = osrvLinkedCondService.insertOsrvLinkedCond(inOsrvLinkedCondVo);
		return getResponseData(inOsrvLinkedCondVo.getCondId());
		
	}
}
